//// REPLICATION FILE /////

** Allison Harell, Keith Banting and Will Kymlicka
** Inclusive Redistribution and Perceptions of Membership: A Cross-National Comparison
** Comparative Political Studies

// Dataset Citation:
** Allison Harell, Keith Banting, Will Kymlicka, Christian Albrekt Larsen, Robert Ford, Gina
** Gustavsson, Pierangelo Isernia and Stuart Soroka. 2022. Intergroup Relations and the
** Foundations of Solidarity (IRFS) Survey. Data Set, Montreal (Canada).

// Software details:
** Stata version 18 syntax, replication file

use "Social Solidarity Study 2021-Final Merged_Weighted.dta"

cd "/Users/lacpop/Dropbox/Allison/Publications/Working Papers/Comparative Political Studies/Replication Files"

*******************************************************************************
***  RECODING VARIABLES 
********************************************************************************

*-------------------------------------------------------------------------------
*** Main IVs and DVs
* standardizing from 0 to 1, consistently using pairwise deletion
*-------------------------------------------------------------------------------

*DVs - general redistribution 
recode Q11 Q13 Q14 (1=0) (2=.25) (3=.5) (4=.75) (5=1) (6=.) (-99=.), gen(redist1 redist3 redist4)
* footnote 10 
alpha redist1 redist3 redist4, gen(redist)
alpha redist1 redist3 redist4 if country=="CA"
alpha redist1 redist3 redist4 if country=="DK"
alpha redist1 redist3 redist4 if country=="FR"
alpha redist1 redist3 redist4 if country=="GB"
alpha redist1 redist3 redist4 if country=="IT"
alpha redist1 redist3 redist4 if country=="SE"
alpha redist1 redist3 redist4 if country=="US"

lab val redist agree

*DVs - inclusive redistribution
recode Q23_3 Q23_2 Q23_1 (-1=0) (-.5=.25) (0=.5) (.5=.75) (1=1)
* footnote 11
alpha Q23_3 Q23_2 Q23_1, gen(incldist_imm2)
alpha Q23_3 Q23_2 Q23_1 if country=="CA"
alpha Q23_3 Q23_2 Q23_1 if country=="DK"
alpha Q23_3 Q23_2 Q23_1 if country=="FR"
alpha Q23_3 Q23_2 Q23_1 if country=="GB"
alpha Q23_3 Q23_2 Q23_1 if country=="IT"
alpha Q23_3 Q23_2 Q23_1 if country=="SE"
alpha Q23_3 Q23_2 Q23_1 if country=="US"

*IVs - Membership perceptions
recode Q17 Q19 Q16 Q20 Q18 Q22 (-1=0) (-.5=.25) (0=.5) (.5=.75) (1=1)
alpha Q17 Q19 Q16 Q20 Q18 Q22, gen(member_imm2)
alpha Q17 Q19 Q16 Q20 Q18 Q22 if country=="CA"
alpha Q17 Q19 Q16 Q20 Q18 Q22 if country=="DK"
alpha Q17 Q19 Q16 Q20 Q18 Q22 if country=="FR"
alpha Q17 Q19 Q16 Q20 Q18 Q22 if country=="GB"
alpha Q17 Q19 Q16 Q20 Q18 Q22 if country=="IT"
alpha Q17 Q19 Q16 Q20 Q18 Q22 if country=="SE"
alpha Q17 Q19 Q16 Q20 Q18 Q22 if country=="US"

encode(country), gen(country_n)

*-------------------------------------------------------------------------------
*** Overview of Attitudinal Controls
*-------------------------------------------------------------------------------

*ethnic versus civic nationalism
recode Q43_1-Q44_2 (-99=.) (5=.) (1=0) (2=.33) (3=.67) (4=1)
lab def important 0 "not at all important" 1 "very important"
lab val (Q43_1-Q44_2) important
gen ethnicnatl=Q44_2 
gen civicnatl=Q44_1
lab val (ethnicnatl civicnatl) important

*strength of national identity
recode Q45 Q46 (-99=.) (1=1) (2=.67) (3=.33) (4=0) (5=.)
lab def ver 1 "very" 0 "not at all"
lab var Q45 "National Identity"
lab var Q46 "National Pride"
lab val (Q45 Q46) very
alpha Q45 Q46, gen(nationalid)
lab val nationalid very

*control (immigrants poor because lazy)
recode Q52_1-Q52_4 (-99=.) (5=.) (1=0) (2=.33) (3=.67) (4=1)
lab val (Q52_1-Q52_4) important
factor Q52_1 Q52_2 Q52_3 Q52_4
gen control=Q52_2
lab val control important

*need
recode Q53 (-99=.) (1=0) (2=.25) (3=.5) (4=.75) (5=1) (6=.)
lab def worse -1 "much more" 1 "much worse"
gen need=Q53
lab val (Q53 need) worse

*-------------------------------------------------------------------------------
*** Sociodemographic Controls
*-------------------------------------------------------------------------------

*Other IVs
*income standardized 
gen income=Q137 
recode income (-99=.) (9/17=.) if country==("CA")
recode income (-99=.) (9/17=.) if country==("FR")
recode income (-99=.) (9/17=.) if country==("GB")
recode income (-99=.) (9/17=.) if country==("US")
recode income (-99=.) (9=.) (10=9) (11=10) (12=11) (13=12) (14=13) (16=14) (17=.) if country==("DK")
recode income (-99=.) (14/17=.) if country==("IT")
recode income (-99=.) (12/17=.) if country==("SE")

gen income_dk=(income-1)/13 if country==("DK")
gen income_it=(income-1)/12 if country==("IT")
gen income_SE=(income-1)/10 if country==("SE")
gen income_s=(income-1)/7 
replace income_s=income_dk if country==("DK")
replace income_s=income_it if country==("IT")
replace income_s=income_SE if country==("SE")

*alternative ordering of countries for presentation
encode(country), gen(country_o)
recode country_o (7=0) (2=5) (5=4) (4=2) 
lab def c_o 0 "US" 1 "CA" 2 "GB" 3 "FR" 4 "IT" 5 "DK" 6 "SE", replace
lab val country_o c_o

*Ideology
gen ideology=Q117_1
recode ideology (-99=5)
recode ideology (0/3=2) (4/6=0) (7/10=1), gen(ideo3)
lab def ideo 0 "centre/dk" 1 "right-wing" 2 "left-wing"
lab val ideo3 ideo

**thermometers
recode Q66_1-Q66_6 (-99=.)
gen therm_immig=Q66_2 if country!=("DK") & country!=("SK")
replace therm_immig=Q66_1 if country==("DK") | country==("SK")
gen therm_imm1=therm_immig/100

*anti immigrant
recode Q57 Q60 (-99=.) (1=0) (2=.25) (3=.5) (4=.75) (5=1) (6=.), gen(goodecon_r enrichcult_r)
recode Q58 Q59 Q61 (-99=.) (1=1) (2=.75) (3=.5) (4=.25) (5=0) (6=.), gen(dontfit takejobs increasecrime)
alpha goodecon_r enrichcult_r dontfit takejobs increasecrime, gen(antimmigrant)

********************************************************************************
***  ANALYSIS - TABLES AND FIGURES CPS 
********************************************************************************

** Figure 1 **

vioplot member_imm2 if foreign==0 [aweight=quota_weight] , over(country_o) hor xtitle("Perceptions of Immigrants' Membership Commitment", size(vsmall))  xlab(0(.5)1) xline(.5, lpattern(dot)) ylabel(, angle(hor)) scheme(s1mono) saving(imm, replace)
graph export Figure1.png, replace

* Calculation of percentages reported in text following Figure 1
gen lowmember=member_imm2
recode lowmember (0/.4999=1) (.5/1=0)
tab lowmember country_o if foreign==0 [aweight=quota_weight], nofreq col

*** Appendix Figure A1 ***

label variable Q17 "Care"
label variable Q16 "Identification"
label variable Q18 "Sacrifice"
label variable Q19 "Contributes"
label variable Q22 "War"
label variable Q20 "Pride"

ciplot Q17 Q16 Q18 Q19 Q22 Q20 if foreign==0 [aweight=quota_weight], hor title("ALL") note("") xscale(range(0 1)) xlab(0(.5)1) xline(.5) saving(ALLi, replace)
graph export ALLimm.png, replace
ciplot Q17 Q16 Q18 Q19 Q22 Q20 if foreign==0 & country=="US" [aweight=quota_weight], hor title("US") note("") xscale(range(0 1)) xlab(0(.5)1) xline(.5) saving(USi, replace)
graph export USimm.png, replace
ciplot Q17 Q16 Q18 Q19 Q22 Q20 if foreign==0 & country=="CA" [aweight=quota_weight], hor title("CA") note("") xscale(range(0 1)) xlab(0(.5)1) xline(.5) saving(CAi, replace)
graph export CAimm.png, replace
ciplot Q17 Q16 Q18 Q19 Q22 Q20 if foreign==0 & country=="GB" [aweight=quota_weight], hor title("GB") note("") xscale(range(0 1)) xlab(0(.5)1) xline(.5) saving(GBi, replace)
graph export GBimm.png, replace
ciplot Q17 Q16 Q18 Q19 Q22 Q20 if foreign==0 & country=="IT" [aweight=quota_weight], hor title("IT") note("") xscale(range(0 1)) xlab(0(.5)1) xline(.5)  saving(ITi, replace)
graph export ITimm.png, replace
ciplot Q17 Q16 Q18 Q19 Q22 Q20 if foreign==0 & country=="SE" [aweight=quota_weight], hor title("SE") note("") xscale(range(0 1)) xlab(0(.5)1) xline(.5)  saving(SEi, replace)
graph export SEimm.png, replace
ciplot Q17 Q16 Q18 Q19 Q22 Q20 if foreign==0 & country=="DK" [aweight=quota_weight], hor title("DK") note("") xscale(range(0 1)) xlab(0(.5)1) xline(.5)  saving(DKi, replace)
graph export DKimm.png, replace
ciplot Q17 Q16 Q18 Q19 Q22 Q20 if foreign==0 & country=="FR" [aweight=quota_weight], hor title("FR") note("") xscale(range(0 1)) xlab(0(.5)1) xline(.5)  saving(FRi, replace)
graph export FRimm.png, replace

graph combine ALLi.gph ITi.gph FRi.gph DKi.gph SEi.gph CAi.gph  USi.gph GBi.gph , note("95% Confidence Interval, Limited to non-foreign born, weighted", size(tiny)) col(2)  xsize(5) ysize(5) scheme(s1mono)
*manually adjusted sizes
graph export figureA1.png, replace

*** Statistics for Table 1 ****

table (country_o) if foreign == 0 [aweight=quota_weight], statistic(mean member_imm2 ethnicnatl civicnatl nationalid) 
table (country_o) if foreign == 0 [aweight=quota_weight], statistic(mean control need therm_imm1 antimmigrant) 
 

** Figure 2, Appendix X

rename (incldist_imm2 redist member_imm2 nationalid ethnicnatl civicnatl control need therm_imm1 ideo3) (InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect Ideology)

* Immigrant - general redistribution

reg GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education income_s age i.country_n  [aweight=quota_weight], beta robust
estimates store imm1
margins, dydx(Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("All Countries") ytitle("") xtitle("General Redistribution") graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Membership" 2 "National ID" 3 "Ethnic Nat'lism" 4 "Civic Nat'lism" 5 "Control" 6 "Need" 7 "Affect" 8 "Right-leaning" 9 "Left-leaning") saving(allc.gph, replace)

reg GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education  income_s age if country=="US", beta robust
estimates store imm2 
margins, dydx(Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono)  xlabel (-.3(.3).6) title("USA") ytitle("") xtitle("General Redistribution") graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Membership" 2 "National ID" 3 "Ethnic Nat'lism" 4 "Civic Nat'lism" 5 "Control" 6 "Need" 7 "Affect" 8 "Right-leaning" 9 "Left-leaning") saving(us.gph, replace)


reg GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education  income_s age if country=="CA", beta robust
estimates store imm3
margins, dydx(Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("Canada") ytitle("") xtitle("General Redistribution") graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Membership" 2 "National ID" 3 "Ethnic Nat'lism" 4 "Civic Nat'lism" 5 "Control" 6 "Need" 7 "Affect" 8 "Right-leaning" 9 "Left-leaning") saving(ca.gph, replace)


reg GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education  income_s  age if country=="GB", beta robust
estimates store imm4
margins, dydx(Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("Great Britain") ytitle("") xtitle("General Redistribution") graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Membership" 2 "National ID" 3 "Ethnic Nat'lism" 4 "Civic Nat'lism" 5 "Control" 6 "Need" 7 "Affect" 8 "Right-leaning" 9 "Left-leaning") saving(gb.gph, replace)


reg GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education  income_s age if country=="IT", beta robust
estimates store imm5
margins, dydx(Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("Italy") ytitle("") xtitle("General Redistribution") graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Membership" 2 "National ID" 3 "Ethnic Nat'lism" 4 "Civic Nat'lism" 5 "Control" 6 "Need" 7 "Affect" 8 "Right-leaning" 9 "Left-leaning") saving(it.gph, replace)


reg GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education  income_s  age if country=="FR", beta robust
estimates store imm6
margins, dydx(Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("France") ytitle("") xtitle("General Redistribution") graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Membership" 2 "National ID" 3 "Ethnic Nat'lism" 4 "Civic Nat'lism" 5 "Control" 6 "Need" 7 "Affect" 8 "Right-leaning" 9 "Left-leaning") saving(fr.gph, replace)


reg GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education  income_s age if country=="DK", beta robust
estimates store imm7
margins, dydx(Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("Denmark") ytitle("") xtitle("General Redistribution") graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Membership" 2 "National ID" 3 "Ethnic Nat'lism" 4 "Civic Nat'lism" 5 "Control" 6 "Need" 7 "Affect" 8 "Right-leaning" 9 "Left-leaning") saving(dk.gph, replace)


reg GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education income_s age if country=="SE", beta robust
estimates store imm8
margins, dydx(Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("Sweden") ytitle("") xtitle("General Redistribution") graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Membership" 2 "National ID" 3 "Ethnic Nat'lism" 4 "Civic Nat'lism" 5 "Control" 6 "Need" 7 "Affect" 8 "Right-leaning" 9 "Left-leaning") saving(SE.gph, replace)

esttab imm1 imm2 imm3 imm4 imm5 imm6 imm7 imm8 using table_2.rtf, b(3) se(3) nogap  replace
graph combine allc.gph us.gph ca.gph gb.gph it.gph fr.gph dk.gph SE.gph, title("") col(2) altshrink xsize(4) ysize(5) scheme(s1mono) saving(Figure2.gph, replace)
graph export figure2.png, replace


* Immigrant (Figure 3, table A2)

reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education  income_s age i.country_n [aweight=quota_weight], beta robust
estimates store imm1
margins, dydx(GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("All Countries") ytitle("") xtitle("Inclusive Redistribution") graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Gen. Redist." 2 "Membership" 3 "National ID" 4 "Ethnic Nat'lism" 5 "Civic Nat'lism" 6 "Control" 7 "Need" 8 "Affect" 9 "Right-leaning" 10 "Left-leaning")  saving(allc.gph, replace)

reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education  income_s age [aweight=quota_weight] if country=="US", robust
estimates store imm2 
margins, dydx(GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("USA") ytitle("") xtitle("Inclusive Redistribution")  graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Gen. Redist." 2 "Membership" 3 "National ID" 4 "Ethnic Nat'lism" 5 "Civic Nat'lism" 6 "Control" 7 "Need" 8 "Affect" 9 "Right-leaning" 10 "Left-leaning")  saving(us.gph, replace)

reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education  income_s age [aweight=quota_weight] if country=="CA", robust
estimates store imm3
margins, dydx(GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("Canada") ytitle("") xtitle("Inclusive Redistribution")  graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Gen. Redist." 2 "Membership" 3 "National ID" 4 "Ethnic Nat'lism" 5 "Civic Nat'lism" 6 "Control" 7 "Need" 8 "Affect" 9 "Right-leaning" 10 "Left-leaning")  saving(ca.gph, replace)

reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education  income_s age [aweight=quota_weight] if country=="GB", robust
estimates store imm4
margins, dydx(GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("Great Britain") ytitle("") xtitle("Inclusive Redistribution")  graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Gen. Redist." 2 "Membership" 3 "National ID" 4 "Ethnic Nat'lism" 5 "Civic Nat'lism" 6 "Control" 7 "Need" 8 "Affect" 9 "Right-leaning" 10 "Left-leaning")  saving(gb.gph, replace)

reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education income_s age [aweight=quota_weight] if country=="IT", robust
estimates store imm5
margins, dydx(GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("Italy") ytitle("") xtitle("Inclusive Redistribution")  graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Gen. Redist." 2 "Membership" 3 "National ID" 4 "Ethnic Nat'lism" 5 "Civic Nat'lism" 6 "Control" 7 "Need" 8 "Affect" 9 "Right-leaning" 10 "Left-leaning")  saving(it.gph, replace)

reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education  income_s age [aweight=quota_weight]  if country=="FR", robust
estimates store imm6
margins, dydx(GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("France") ytitle("") xtitle("Inclusive Redistribution")  graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Gen. Redist." 2 "Membership" 3 "National ID" 4 "Ethnic Nat'lism" 5 "Civic Nat'lism" 6 "Control" 7 "Need" 8 "Affect" 9 "Right-leaning" 10 "Left-leaning")  saving(fr.gph, replace)

reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education  income_s age [aweight=quota_weight]  if country=="DK", robust
estimates store imm7
margins, dydx(GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("Denmark") ytitle("") xtitle("Inclusive Redistribution")  graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Gen. Redist." 2 "Membership" 3 "National ID" 4 "Ethnic Nat'lism" 5 "Civic Nat'lism" 6 "Control" 7 "Need" 8 "Affect" 9 "Right-leaning" 10 "Left-leaning")  saving(dk.gph, replace)

reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education income_s age [aweight=quota_weight]  if country=="SE", robust
estimates store imm8
margins, dydx(GenRedist Membership NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology)
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) scheme(s1mono) xlabel (-.3(.3).6) title("Sweden") ytitle("") xtitle("Inclusive Redistribution")  graphregion(margin(l+20 r+1)) ///
  ylabel(1 "Gen. Redist." 2 "Membership" 3 "National ID" 4 "Ethnic Nat'lism" 5 "Civic Nat'lism" 6 "Control" 7 "Need" 8 "Affect" 9 "Right-leaning" 10 "Left-leaning")  saving(SE.gph, replace)

esttab imm1 imm2 imm3 imm4 imm5 imm6 imm7 imm8 using table_1.rtf, b(3) se(3) nogap  replace
graph combine allc.gph us.gph ca.gph gb.gph it.gph fr.gph dk.gph SE.gph, title("") col(2) altshrink xsize(5) ysize(6) scheme(s1mono) saving(Figure3.gph, replace)
graph export figure3.png, replace

// Figure 4 and Table A6

reg InclusiveRedist GenRedist c.Membership##i.country_o NationalID EthnicNatl CivicNatl Control Need Affect i.Ideology gender i.religion2 foreign education income_s age [aweight=quota_weight], beta robust
estimates store interaction
esttab interaction using table_5a.rtf, b(3) se(3) nogap  replace
margins, at(Membership=(.0 .5 1) country_o=(0(1)6))
marginsplot, title("") xtitle("Membership Perceptions") ytitle("Inclusive Redistribution") ylabel(0(.25)1, nogrid)  xlabel(0 .5 1, nogrid) scheme(modern) xsize(4) ysize(3) saving(Figure4.gph, replace)
graph export Figure4.png, replace

esttab interaction using table6.rtf, b(3) se(3) nogap replace


** rerunning models with anti immigrant scale (table b3) ***

reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need antimmigrant i.Ideology gender i.religion2 foreign education  income_s age i.country_n [aweight=quota_weight], robust
estimates store imm1
reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need antimmigrant i.Ideology gender i.religion2 foreign education  income_s age [aweight=quota_weight] if country=="US", robust
estimates store imm2
reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need antimmigrant i.Ideology gender i.religion2 foreign education  income_s age [aweight=quota_weight] if country=="CA", robust
estimates store imm3
reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need antimmigrant i.Ideology gender i.religion2 foreign education  income_s age [aweight=quota_weight] if country=="GB", robust
estimates store imm4
reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need antimmigrant i.Ideology gender i.religion2 foreign education  income_s age [aweight=quota_weight] if country=="IT", robust
estimates store imm5
reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need antimmigrant i.Ideology gender i.religion2 foreign education  income_s age [aweight=quota_weight] if country=="FR", robust
estimates store imm6
reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need antimmigrant i.Ideology gender i.religion2 foreign education  income_s age [aweight=quota_weight] if country=="DK", robust
estimates store imm7
reg InclusiveRedist GenRedist Membership NationalID EthnicNatl CivicNatl Control Need antimmigrant i.Ideology gender i.religion2 foreign education  income_s age [aweight=quota_weight] if country=="SE", robust
estimates store imm8
esttab imm1 imm2 imm3 imm4 imm5 imm6 imm7 imm8 using table_b3.rtf, b(3) se(3) nogap  replace



** Additional information for Appendix

*table A1 median times
summarize time if country_n==1, detail
summarize time if country_n==2, detail
summarize time if country_n==3, detail
summarize time if country_n==4, detail
summarize time if country_n==5, detail
summarize time if country_n==6, detail
summarize time if country_n==7, detail

* table A2
*gender
mean gender, over(country_n)

*age
*convert age sequential to real age
gen age_real=age+15

summarize age_real if country_n==1, detail
summarize age_real if country_n==2, detail
summarize age_real if country_n==3, detail
summarize age_real if country_n==4, detail
summarize age_real if country_n==5, detail
summarize age_real if country_n==6, detail
summarize age_real if country_n==7, detail

recode age_real (18/34=0) (35/54=1) (55/90=2), gen(age3)
tab age3 country_n, col

*born abroad
mean foreign, over(country_n)

*education
*create age category to match oedc data
recode age_real (18/23=0) (24/65=1) (65/99=0),gen(oecdage)
tab country_n education  if oecdage==1, row


